#!/bin/bash

if [ -e /boot/emmcboot.itb ]; then
	cp /boot/emmcboot.itb /boot/emmcboot.itb.bak
fi
if [ -e /boot/spi_flash.bin ]; then
	cp /boot/spi_flash.bin /boot/spi_flash.bin.bak
fi
if [ -e /boot/multi.its ]; then
	cp /boot/multi.its /boot/multi.its.bak
fi
if [ -e /boot/boot.scr.emmc ]; then
	cp /boot/boot.scr.emmc /boot/boot.scr.emmc.bak
fi

# we are installing to a FAT32 partion, dpkg won't be able to create backup link
# before installing new version, so we remove the files for it here to avoid error.
rm -f /boot/emmcboot.itb
rm -f /boot/multi.its
rm -f /boot/spi_flash.bin
rm -f /boot/boot.scr.emmc
